<?php
/**
 * @file statisticcategory.php $
 * @author LinLin (linlin@haibao.com) $
 * @date 2015-9-16 下午5:05:16 $
 * @brief  $
 */
namespace haibao\app\data;

class StatisticCategory extends \haibao\app\data\BaseMysql{

	public function __construct(){
		parent::__construct('\haibao\app\model\data\StatisticCategory');
	}
	
	private static $typeAction = 'action';
	
	/**
	 * 获得行为列表
	 * @return multitype:multitype:NULL Ambigous <NULL, \DateTime>
	 */
	public function getAppActionCountList(){
		$result = $this->query('select * from StatisticCategory');
		$list = array();
		$actionList = array();
		while($result->fetch_assoc()){
			$list['Id'] = $result->getData('Id');
			$list['Name'] = $result->getData('Name');
			$list['Code'] = $result->getData('Code');
			$actionList[] = $list;
		}
		return $actionList;
	}

	/**
	 * 添加行为名称
	 */
	public function addAction($model){
		$this->add($model);
	}
	
	/**
	 * 检查行为名称，编码检查是否重复
	 * @param unknown $action
	 * @return multitype:multitype:NULL Ambigous <NULL, \DateTime>
	 */
	public function getAppAction($action,$type){
		$actionList = array();
		if($type == self::$typeAction){
			$result = $this->query("select * from `StatisticCategory` where Name = %s",array($action));
		}else {
			$result = $this->query("select * from `StatisticCategory` where Code = %s",array($action));
		}
		$list = array();
		while($result->fetch_assoc()){
			$list['Name'] = $result->getData('Name');
			$list['Code'] = $result->getData('Code');
			$actionList[] = $list;
		}
		return $actionList;
	}
}